const Koa = require('koa');
const serve = require('koa-static');
const path = require('path');
const koaBody = require('koa-body');

// mongodb连接
// const mongodb = require('./mongodb');

const router = require('./router');

const { ctxxmlhandle } = require('./utils/xml2js');
const resolve = dir => path.join(__dirname, dir);

// mongodb().then(() => {

//   const app = new Koa();
//   const wechat = new Wechat();

//   app
//   .use(ctxxmlhandle)
//   .use(router.routes());

//   app.listen(8999);
//   console.log('server start at post:' + 8999);
// });

const app = new Koa();
const port = 4040;

app
// .use(bodyParser())
.use(koaBody({
  multipart: true,
}))
.use(serve(resolve('./views')))
.use(ctxxmlhandle)
.use(router.routes())

app.listen(port, () => console.log('server start at post:' + port));